import time

from www.orm import Model, IntField, StringField, DateTimeField, BooleanField, FloatField, TextField


class User(Model):
    __table__ = 'user'
    id = IntField(primary_key=True)
    nick_name = StringField()
    account = StringField()
    password = StringField()
    create_at = DateTimeField()
    age = IntField(primary_key=False)


class User(Model):
    __table__ = 'users'

    id = IntField(primary_key=True)
    email = StringField(ddl='varchar(50)')
    passwd = StringField(ddl='varchar(50)')
    admin = BooleanField()
    name = StringField(ddl='varchar(50)')
    image = StringField(ddl='varchar(500)')
    created_at = FloatField(default=time.time())


class Blog(Model):
    __table__ = 'blogs'

    id = IntField(primary_key=True)
    user_id = StringField(ddl='varchar(50)')
    user_name = StringField(ddl='varchar(50)')
    user_image = StringField(ddl='varchar(500)')
    name = StringField(ddl='varchar(50)')
    summary = StringField(ddl='varchar(200)')
    content = TextField()
    created_at = FloatField(default=time.time())


class Comment(Model):
    __table__ = 'comments'

    id = IntField(primary_key=True)
    blog_id = StringField(ddl='varchar(50)')
    user_id = StringField(ddl='varchar(50)')
    user_name = StringField(ddl='varchar(50)')
    user_image = StringField(ddl='varchar(500)')
    content = TextField()
    created_at = FloatField(default=time.time())
